package com.com.corejavalearnings.generics.designpattern.strategy;

import org.junit.*;

import java.util.logging.Logger;

/**
 * Created by pankaj on 7/26/15.
 */
public class TestStrategyPattern {
    static Logger logger = Logger.getLogger(TestStrategyPattern.class.getName());

    static {
        logger.setParent(Logger.getLogger(TestStrategyPattern.class.getPackage().getName()));
    }

    @BeforeClass
    public static void setUpOnce(){

    }

    @Before
    public void setUp(){

    }

    @Test
    public void testDefaultStrategy()
    {
        Person person = new Person(10000000);
        TaxStrategy strategy = new DefaultTaxStrategy();
        double taxAmount = strategy.compute(person);
        assert taxAmount == 4000000;
    }

    @Test
    public void testNonProfitTrustTaxStrategy()
    {
        Trust nonProfit = new Trust(10000000, true);
        TaxStrategy trustStrategy = new TrustTaxStrategy();
        double taxAmount = trustStrategy.compute(nonProfit);
        assert taxAmount == 0;
    }

    @Test
    public void testProfitTrustTaxStrategy()
    {
        Trust forProfit = new Trust(10000000, false);
        TaxStrategy trustStrategy = new TrustTaxStrategy();
        double taxAmount = trustStrategy.compute(forProfit);
        assert taxAmount == 4000000;
    }


    @After
    public void tearDown(){
        // clean up fixtures if necessary i.e non memory resources connections files
    }

    @AfterClass
    public static void tearDownOnce(){
        // clean up just once
    }
}
